﻿using System.Collections.Generic;
using FluentNHibernate.Mapping;

namespace Model
{
	public class AchievementCategory
	{
		public virtual int ID { get; set; }
		public virtual string Name { get; set; }
		public virtual int ExternalKey { get; set; }
		public virtual AchievementCategory Parent { get; set; }

		private IList<AchievementCategory> _children = new List<AchievementCategory>();
		public virtual IList<AchievementCategory> Children { get { return _children; } set { _children = value; } }

		private IList<Achievement> _achievements = new List<Achievement>();
		public virtual IList<Achievement> Achievements { get { return _achievements; } set { _achievements = value; } }
	}

	public class AchievementCategoryMapping : ClassMap<AchievementCategory>
	{
		public AchievementCategoryMapping()
		{
			Id(x => x.ID);
			Map(x => x.Name);
			Map(x => x.ExternalKey);
			References(x => x.Parent).Column("Parent_id");
			HasMany(x => x.Children).KeyColumn("Parent_id");
			HasMany(x => x.Achievements).KeyColumn("Category_id");
		}
	}
}
